package cachex

import (
	"time"
)

var C Cache

type Cache interface {
	Set(key, val string, expiration time.Duration) error
	SetNoExpiration(key, val string) error
	Get(key string) (string, error)
	Del(keys ...string) error
	Clear() error
}

func InitCache(cfg Config) error {
	switch cfg.Type {
	case "redis":
		var err error
		if C, err = NewRedisCache(cfg); err != nil {
			return err
		}
	default:
		C = NewGoCache()
	}
	return nil
}
